#pragma once

#include <memory>
#include <string>
#include <vector>

// #include "base/common/logging.h"
#include <butil/logging.h>
#include "doca_dev.h"

#define DOCA_CHECK(error)                                                       \
  do {                                                                         \
    auto err = error;                                                          \
    if (err != DOCA_SUCCESS) {                                                 \
      LOG(ERROR) << "Check doca status failed: " << doca_error_get_descr(err); \
    }                                                                          \
  } while (0)

#define DOCA_CHECK_ERROR(error)                                                 \
  do {                                                                         \
    auto err = error;                                                          \
    if (err != DOCA_SUCCESS) {                                                 \
      LOG(ERROR) << "Check doca status failed: " << doca_error_get_descr(err); \
    }                                                                          \
  } while (0)

#define DOCA_CHECK_FATAL(error)                                              \
  do {                                                                       \
    auto err = error;                                                        \
    if (err != DOCA_SUCCESS) {                                                \
      LOG(FATAL) << "Check doca status failed: " << doca_error_get_descr(err); \
    }                                                                        \
  } while (0)

#define DOCA_CHECK_RETURN(error)                                             \
  do {                                                                       \
    auto err = error;                                                        \
    if (err != DOCA_SUCCESS) {                                                \
      LOG(ERROR) << "Check doca status failed: " << doca_error_get_descr(err); \
      return;                                                                \
    }                                                                        \
  } while (0)

#define DOCA_CHECK_RETURN_VAL(error, val)                                    \
  do {                                                                       \
    auto err = error;                                                        \
    if (err != DOCA_SUCCESS) {                                                \
      LOG(ERROR) << "Check doca status failed: " << doca_error_get_descr(err); \
      return val;                                                            \
    }                                                                        \
  } while (0)

#define DOCA_CHECK_RETURN_FALSE(error)                                       \
  do {                                                                       \
    auto err = error;                                                        \
    if (err != DOCA_SUCCESS) {                                                \
      LOG(ERROR) << "Check doca status failed: " << doca_error_get_descr(err); \
      return false;                                                          \
    }                                                                        \
  } while (0)

